/**
 * 
 */
({
	single:true,
	launch : function() {
		var me = this;
		$.post(me.ctx + "/manager/account", {}, function(data) {
			if(data.success) {
				var account = data.message;
				var source = '<div>';
				source += '<div>';
				source += '<div title="基础信息" style="padding:10px;">';
				source += '<form style="width:100%;" method="post">';
				source += '<table width="100%" class="form-table">';
				source += "<tr>";
				source += '<td style="width:60px">账　　号：</td>';
				source += '<td>'+account.account+'</td>';
				source += "</tr>";
				source += "<tr>";
				source += '<td>姓　　名：</td>';
				source += '<td>'+account.name+'</td>';
				source += "</tr>";
				source += "<tr>";
				source += '<td>状　　态：</td>';
				source += '<td>'+ (account.status === '1' ? '启用' : '停用') + '</td>';
				source += "</tr>";
				source += "<tr>";
				source += '<td>创建时间：</td>';
				source += '<td>'+ account.createtime + '</td>';
				source += "</tr>";
				source += '</table></form></div>';
				source += '<div title="修改密码" style="padding:10px;">';
				source += '<form style="width:100%;" method="post"><div>';
				source += '<table width="100%" class="form-table">';
				source += '</table></div></form></div>';
				source += '</div>';
				source += '</div>';
				var win = me.createWindow(source, {
					title:"我的信息",
					width:300,
					height:215,
					resizable:false,
					maximizable:false
				});
				var tab = win.children("div");
				var panel = tab.children("div:eq(1)");
				tab.tabs({
					fit:true
				});
				var table = panel.find("table");
				var row = table.row();
				row.cell("原密码：", {width:"60px"});
				var pid = uuid.create();
				var field = $('<input type="password" name="oldPassword" style="width:100%;" />');
				row.cell(field);
				field.textbox({
					required:true,
					validType : ['minlength[6]']
				});
				row = table.row();
				row.cell("新密码：");
				field = $('<input id="'+pid+'" type="password" name="password" style="width:100%;" />');
				row.cell(field);
				field.textbox({
					required:true,
					validType : ['minlength[6]']
				});
				row = table.row();
				row.cell("确认密码：");
				field = $('<input type="password" name="confirmpassword" style="width:100%;" />');
				row.cell(field);
				field.textbox({
					required:true,
					validType : ['password["#'+pid+'"]']
				});
				
				var form = panel.find("form");
				form.form({
					url : me.ctx + "/manager/password",
					success: function(data){
						$.messager.mask("close");
				        var data = eval('(' + data + ')');
				        if (data.success){
				        	form.form("load", {
				        		oldPassword:"",
				        		password:"",
				        		confirmpassword:""
				        	});
				            $.messager.alert('提示：', "密码更新成功！", "info");
				        } else {
				        	$.messager.alert('提示：', "密码更新失败！", "info");
				        }
				    }
				});
				var footer = $('<div style="padding:0;text-align:right;"></div>');
				var saveButton = $('<a href="#">提交</a>').appendTo(footer);
				saveButton.linkbutton({
					iconCls : 'icon-ok',
					onClick : function() {
						if(form.form("validate")) {
							$.messager.mask().text("操作执行中，请稍后……");
							form.form("submit");
						}
						return false;						
					}
				});
				row = table.row();
				row.cell(footer, {colspan:"2"});
				
			}
		}, "json");
	}
})